/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package mx.edu.itschapala.sistemas.septimo.vista;

import javax.swing.JFrame;
import javax.swing.UIManager;
import mx.edu.itschapala.sistemas.septimo.control.*;
import mx.edu.itschapala.sistemas.septimo.modelo.*;
import mx.edu.itschapala.sistemas.septimo.vista.enumeracion.TipoVentana;

/**
 *
 * @author Miguel Romero
 */
public class MenuPrincipal extends javax.swing.JFrame {
private JFrame productoVentanaRegistro;
private JFrame productoVentanaEditar;
private JFrame productoVentanaEliminar;
private JFrame productoVentanaBuscar;
private JFrame productoVentana;
private JFrame clienteVentanaRegistro;
private JFrame clienteVentanaEditar;
private JFrame clienteVentanaEliminar;
private JFrame clienteVentanaBuscar;
private JFrame clienteVentana;    
private JFrame ventaVentana; 
private JFrame ventaVentanaRegistro;
private JFrame ventaVentaListar;
     /**
     * Creates new form MenuPrincipal
     */
    public MenuPrincipal() {
        try{
            UIManager.setLookAndFeel("com.jtattoo.plaf.graphite.GraphiteLookAndFeel");
            }catch(Exception ex){
                ex.printStackTrace();
        }
        initComponents();
        productoControl.registrar(new Producto(1, "JABON", 12.5f, "ABAROTE", "JABON NEUTRO"));
        productoControl.registrar(new Producto(2, "PEPSI", 12.5f, "ABAROTE", "AGUA NEGRA"));
        productoControl.registrar(new Producto(3, "JAMON", 12.5f, "ABAROTE", "JAMON NEGRO"));
        productoControl.registrar(new Producto(4, "SAL",   12.5f, "ABAROTE", "SAL CRISTAL"));
        productoControl.registrar(new Producto(5, "YYY",   12.5f, "ABAROTE", "JABON Y"));
        productoControl.registrar(new Producto(6, "SALVO", 12.5f, "ABAROTE", "JABON QUE SALVA"));
        productoControl.registrar(new Producto(7, "LECHI", 12.5f, "ABAROTE", "LECHE DE VAQUILA"));
        
        clienteControl.clienregistrar(new Cliente ("ANA"   ,"MUJER" ,1,33123456, "AV CHOSTUMO"));
        clienteControl.clienregistrar(new Cliente ("PABLO" ,"HOMBRE",2,33123457, "AV MATAMOROS"));
        clienteControl.clienregistrar(new Cliente ("PEDRO" ,"HOMBRE",3,33123458, "AV SANTIAGO"));
        clienteControl.clienregistrar(new Cliente ("MIGUEL","HOMBRE",4,33123459, "AV SIEMPRE VIVA"));
        clienteControl.clienregistrar(new Cliente ("MICHEL","MUJER" ,5,33123460, "AV IGNACIO ALLENDE"));
        clienteControl.clienregistrar(new Cliente ("RAUL"  ,"HOMBRE",6,33123461, "AV CERNICALO DESCONPUESTO"));
        clienteControl.clienregistrar(new Cliente ("CESAR" ,"HOMBRE",7,33123462, "AV NOPALERA"));
        clienteControl.clienregistrar(new Cliente ("MARIO" ,"HOMBRE",8,33123463, "AV CHANPIÑON ROJO"));
        clienteControl.clienregistrar(new Cliente ("LUIGI" ,"HOMBRE",9,33123464, "AV CHANPIÑON VERDE"));        
        clienteControl.clienregistrar(new Cliente ("PEACH" ,"MUJER",10,33123465, "AV CHANPIÑON ROSA"));
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jMenuBar1 = new javax.swing.JMenuBar();
        jMenu1 = new javax.swing.JMenu();
        jMenuItem1 = new javax.swing.JMenuItem();
        jMenuItem2 = new javax.swing.JMenuItem();
        jMenuItem3 = new javax.swing.JMenuItem();
        jMenuItem4 = new javax.swing.JMenuItem();
        jMenuItem5 = new javax.swing.JMenuItem();
        jMenu2 = new javax.swing.JMenu();
        jMenuItem6 = new javax.swing.JMenuItem();
        jMenuItem7 = new javax.swing.JMenuItem();
        jMenuItem8 = new javax.swing.JMenuItem();
        jMenuItem9 = new javax.swing.JMenuItem();
        jMenuItem10 = new javax.swing.JMenuItem();
        jMenu3 = new javax.swing.JMenu();
        jMenuItem11 = new javax.swing.JMenuItem();
        jMenuItem12 = new javax.swing.JMenuItem();
        jMenu4 = new javax.swing.JMenu();
        jMenuItem13 = new javax.swing.JMenuItem();
        jMenuItem14 = new javax.swing.JMenuItem();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowOpened(java.awt.event.WindowEvent evt) {
                formWindowOpened(evt);
            }
        });
        getContentPane().setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        jPanel1.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());
        jPanel1.add(jLabel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, 420, 310));

        getContentPane().add(jPanel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, -1, -1));

        jMenu1.setText("Producto");

        jMenuItem1.setText("Registrar");
        jMenuItem1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem1ActionPerformed(evt);
            }
        });
        jMenu1.add(jMenuItem1);

        jMenuItem2.setText("Editar unProducto");
        jMenuItem2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem2ActionPerformed(evt);
            }
        });
        jMenu1.add(jMenuItem2);

        jMenuItem3.setText("Buscar un Producto");
        jMenuItem3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem3ActionPerformed(evt);
            }
        });
        jMenu1.add(jMenuItem3);

        jMenuItem4.setText("Eliminar un producto");
        jMenuItem4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem4ActionPerformed(evt);
            }
        });
        jMenu1.add(jMenuItem4);

        jMenuItem5.setText("Listar todos los Productos");
        jMenuItem5.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem5ActionPerformed(evt);
            }
        });
        jMenu1.add(jMenuItem5);

        jMenuBar1.add(jMenu1);

        jMenu2.setText("Clentes");

        jMenuItem6.setText("Registrar un Cliente");
        jMenuItem6.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem6ActionPerformed(evt);
            }
        });
        jMenu2.add(jMenuItem6);

        jMenuItem7.setText("Editar un cliente");
        jMenuItem7.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem7ActionPerformed(evt);
            }
        });
        jMenu2.add(jMenuItem7);

        jMenuItem8.setText("Buscar un Cliente");
        jMenuItem8.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem8ActionPerformed(evt);
            }
        });
        jMenu2.add(jMenuItem8);

        jMenuItem9.setText("Eliminar un Cliente");
        jMenuItem9.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem9ActionPerformed(evt);
            }
        });
        jMenu2.add(jMenuItem9);

        jMenuItem10.setText("Listar todos los Clientes");
        jMenuItem10.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem10ActionPerformed(evt);
            }
        });
        jMenu2.add(jMenuItem10);

        jMenuBar1.add(jMenu2);

        jMenu3.setText("Ventas");

        jMenuItem11.setText("Hacer una venta");
        jMenuItem11.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem11ActionPerformed(evt);
            }
        });
        jMenu3.add(jMenuItem11);

        jMenuItem12.setText("Listar todas las Ventas");
        jMenuItem12.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem12ActionPerformed(evt);
            }
        });
        jMenu3.add(jMenuItem12);

        jMenuBar1.add(jMenu3);

        jMenu4.setText("Ayuda");

        jMenuItem13.setText("Acerca de");
        jMenu4.add(jMenuItem13);

        jMenuItem14.setText("Tutoriales e linea");
        jMenu4.add(jMenuItem14);

        jMenuBar1.add(jMenu4);

        setJMenuBar(jMenuBar1);

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private ProductoLnLocal productoControl = new ProductoLnLista();
    private ClienteLnLocal clienteControl = new ClienteLnLista();
    private VentaLnLocal ventaControl = new VentaLnLista();
    
    private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem1ActionPerformed
        //new ProductoCrearEditar(null,productoControl,TipoVentana.VENTANA_REGISTRO).setVisible(true);
        if(productoVentanaRegistro==null){
            productoVentanaRegistro=new ProductoCrearEditar(null,productoControl,TipoVentana.VENTANA_REGISTRO);
        }
        productoVentanaRegistro.setVisible(true);
    }//GEN-LAST:event_jMenuItem1ActionPerformed

    private void formWindowOpened(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowOpened
        
    }//GEN-LAST:event_formWindowOpened

    private void jMenuItem3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem3ActionPerformed
        //new ProductoCrearEditar(null,productoControl,TipoVentana.VENTANA_BUSQUEDA).setVisible(true);
        if(productoVentanaBuscar==null){
            productoVentanaBuscar=new ProductoCrearEditar(null,productoControl,TipoVentana.VENTANA_BUSQUEDA);
        }
        productoVentanaBuscar.setVisible(true);
    }//GEN-LAST:event_jMenuItem3ActionPerformed

    private void jMenuItem2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem2ActionPerformed
        //new ProductoCrearEditar(null,productoControl, TipoVentana.VENTANA_MODIFICAR).setVisible(true);
        if(productoVentanaEditar==null){
            productoVentanaEditar=new ProductoCrearEditar(null,productoControl,TipoVentana.VENTANA_MODIFICAR);
        }
        productoVentanaEditar.setVisible(true);
    }//GEN-LAST:event_jMenuItem2ActionPerformed

    private void jMenuItem5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem5ActionPerformed

///////////////////////////lISTAR LOS PRODUCTOS////////////////////////////
        if(productoVentana==null){
            productoVentana=new ProductoListar(productoControl);
        }
        productoVentana.setVisible(true);
    }//GEN-LAST:event_jMenuItem5ActionPerformed

    private void jMenuItem9ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem9ActionPerformed
    //new ClienteCrearEditar(null,clienteControl, TipoVentana.VENTANA_ELIMINAR).setVisible(true);
    if(clienteVentanaEliminar==null){
            clienteVentanaEliminar=new ClienteCrearEditar(null,clienteControl,TipoVentana.VENTANA_ELIMINAR);
        }
        clienteVentanaEliminar.setVisible(true);
    }//GEN-LAST:event_jMenuItem9ActionPerformed

    private void jMenuItem10ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem10ActionPerformed
        if(clienteVentana==null){
            clienteVentana=new ClienteListar(clienteControl);
        }
        clienteVentana.setVisible(true);
    }//GEN-LAST:event_jMenuItem10ActionPerformed

    private void jMenuItem4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem4ActionPerformed
        //new ProductoCrearEditar(null,productoControl, TipoVentana.VENTANA_ELIMINAR).setVisible(true);
        if(productoVentanaEliminar==null){
            productoVentanaEliminar=new ProductoCrearEditar(null,productoControl,TipoVentana.VENTANA_ELIMINAR);
        }
        productoVentanaEliminar.setVisible(true);
    }//GEN-LAST:event_jMenuItem4ActionPerformed

    private void jMenuItem6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem6ActionPerformed
        //new ClienteCrearEditar(null,clienteControl, TipoVentana.VENTANA_REGISTRO).setVisible(true);
        if(clienteVentanaRegistro==null){
            clienteVentanaRegistro=new ClienteCrearEditar(null,clienteControl,TipoVentana.VENTANA_REGISTRO);
        }
        clienteVentanaRegistro.setVisible(true);
    }//GEN-LAST:event_jMenuItem6ActionPerformed

    private void jMenuItem7ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem7ActionPerformed
        //new ClienteCrearEditar(null,clienteControl, TipoVentana.VENTANA_MODIFICAR).setVisible(true);
        if(clienteVentanaEditar==null){
            clienteVentanaEditar=new ClienteCrearEditar(null,clienteControl,TipoVentana.VENTANA_MODIFICAR);
        }
        clienteVentanaEditar.setVisible(true);
    }//GEN-LAST:event_jMenuItem7ActionPerformed

    private void jMenuItem8ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem8ActionPerformed
        //new ClienteCrearEditar(null,clienteControl, TipoVentana.VENTANA_BUSQUEDA).setVisible(true);
        if(clienteVentanaBuscar==null){
            clienteVentanaBuscar=new ClienteCrearEditar(null,clienteControl,TipoVentana.VENTANA_BUSQUEDA);
        }
        clienteVentanaBuscar.setVisible(true);
    }//GEN-LAST:event_jMenuItem8ActionPerformed

    private void jMenuItem11ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem11ActionPerformed
        if(ventaVentanaRegistro==null){
            ventaVentanaRegistro=new VentaCrearEditar(null, ventaControl, productoControl, clienteControl, TipoVentana.VENTANA_REGISTRO);
        }
        ventaVentanaRegistro.setVisible(true);
    }//GEN-LAST:event_jMenuItem11ActionPerformed

    private void jMenuItem12ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem12ActionPerformed
        if(ventaVentana==null){
            ventaVentana=new VentaListar(ventaControl);
        }
        ventaVentana.setVisible(true);
    }//GEN-LAST:event_jMenuItem12ActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(MenuPrincipal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(MenuPrincipal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(MenuPrincipal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(MenuPrincipal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new MenuPrincipal().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel jLabel1;
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenu jMenu2;
    private javax.swing.JMenu jMenu3;
    private javax.swing.JMenu jMenu4;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JMenuItem jMenuItem1;
    private javax.swing.JMenuItem jMenuItem10;
    private javax.swing.JMenuItem jMenuItem11;
    private javax.swing.JMenuItem jMenuItem12;
    private javax.swing.JMenuItem jMenuItem13;
    private javax.swing.JMenuItem jMenuItem14;
    private javax.swing.JMenuItem jMenuItem2;
    private javax.swing.JMenuItem jMenuItem3;
    private javax.swing.JMenuItem jMenuItem4;
    private javax.swing.JMenuItem jMenuItem5;
    private javax.swing.JMenuItem jMenuItem6;
    private javax.swing.JMenuItem jMenuItem7;
    private javax.swing.JMenuItem jMenuItem8;
    private javax.swing.JMenuItem jMenuItem9;
    private javax.swing.JPanel jPanel1;
    // End of variables declaration//GEN-END:variables
}
